/* 基础样式 */
:root {
  --huawei-red: #0a3b7d;
  --huawei-light-red: #1a59b7;
  --huawei-dark-red: #062a5e;
  --huawei-grey: #f7f7f7;
  --huawei-dark-grey: #666;
  --huawei-text: #2a2a2a;
  --border-radius: 4px;
  --box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* 悬浮按钮 */
.chatToggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: var(--huawei-red);
  color: white;
  border: none;
  border-radius: 24px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  z-index: 1000;
  box-shadow: var(--box-shadow);
  transition: background-color 0.3s;
}

.chatToggle:hover {
  background-color: var(--huawei-dark-red);
}

/* 聊天窗口容器 */
.chatWidget {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  height: 85%;
  max-width: 1200px;
  max-height: 700px;
  z-index: 1000;
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--box-shadow);
}

.chatContainer {
  display: grid;
  grid-template-columns: 240px minmax(auto, 800px) 1fr;
  height: 100%;
  background-color: white;
  overflow: hidden;
}

/* 左侧面板 */
.leftPanel {
  background: linear-gradient(145deg, #0a3b7d 0%, #062456 100%);
  color: white;
  padding: 20px 15px;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  position: sticky;
  top: 0;
  grid-column: 1;
  z-index: 2;
}

.brandTitle {
  text-align: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

.brandTitle h2 {
  font-size: 20px;
  margin: 0;
  font-weight: bold;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  letter-spacing: 1px;
}

.hotQuestionSection {
  flex: 1;
}

.hotQuestionTitle {
  text-align: center;
  font-size: 14px;
  font-weight: bold;
  margin-bottom: 15px;
  position: relative;
}

.hotQuestionTitle:before,
.hotQuestionTitle:after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40px;
  height: 1px;
  background-color: rgba(255, 255, 255, 0.3);
}

.hotQuestionTitle:before {
  left: 10px;
}

.hotQuestionTitle:after {
  right: 10px;
}

.hotQuestionList {
  list-style: none;
  padding: 0;
  margin: 0;
}

.hotQuestionList li {
  padding: 10px;
  margin-bottom: 6px;
  border-radius: 2px;
  font-size: 13px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.hotQuestionList li:hover {
  background-color: rgba(255, 255, 255, 0.15);
}

/* 中间面板 */
.middlePanel {
  background-color: #fff;
  display: flex;
  flex-direction: column;
  border-left: 1px solid #f0f0f0;
  border-right: 1px solid #f0f0f0;
  height: 100%;
  overflow: hidden;
  grid-column: 2;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
  z-index: 1;
}

.chatHeader {
  flex-shrink: 0;
  background-color: var(--huawei-red);
  padding: 12px 20px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chatHeader span {
  font-weight: bold;
  color: white;
  font-size: 16px;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

.closeButton {
  background: none;
  border: none;
  font-size: 22px;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
}

.closeButton:hover {
  color: white;
}

/* 粒子背景 */
.particleBackground {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
}

/* 聊天窗口容器 - 新增 */
.chatWidgetContainer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
}

.chatContainer {
    width: 90%;
    max-width: 800px;
    height: 80vh;
    max-height: 700px;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.middlePanel {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* 确保聊天消息区域可以滚动且占据剩余空间 */
.chatMessages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
}

/* 确保控制区域固定在底部 */
.chatControls {
    flex-shrink: 0;
    padding: 15px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    background-color: rgba(10, 59, 125, 0.8);
    z-index: 2;
}
.chatContainer {
    position: relative;
    z-index: 1;
    /* 可以添加半透明背景以便更好地显示内容 */
    background-color: rgba(255, 255, 255, 0.8);
}

.particleBackground::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0) 70%);
  z-index: 1;
}

.particleBackground::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(0, 102, 204, 0.1) 0%, rgba(0, 102, 204, 0) 20%),
    radial-gradient(circle at 90% 80%, rgba(0, 102, 204, 0.1) 0%, rgba(0, 102, 204, 0) 20%),
    radial-gradient(circle at 50% 50%, rgba(0, 102, 204, 0.05) 0%, rgba(0, 102, 204, 0) 60%);
  z-index: 1;
  animation: particleMove 20s infinite linear;
}

@keyframes particleMove {
  0% {
    background-position: 0% 0%, 0% 0%, 0% 0%;
  }
  25% {
    background-position: 10% 10%, -5% 5%, 3% -10%;
  }
  50% {
    background-position: 5% 15%, -10% 10%, -5% 5%;
  }
  75% {
    background-position: -5% 10%, 5% 5%, 10% 0%;
  }
  100% {
    background-position: 0% 0%, 0% 0%, 0% 0%;
  }
}

/* 常见问题区域 */
.commonQuestions {
  flex-shrink: 0;
  padding: 15px;
  border-bottom: 1px solid #e1e4e8;
  background-color: #f9f9f9;
}

.commonQuestionItem {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
}

.commonQuestionItem:last-child {
  border-bottom: none;
}

.commonQuestionItem:hover {
  background-color: #f0f2f5;
}

.arrowIcon {
  font-style: normal;
  color: #aaa;
  font-size: 18px;
}

.searchMore {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
  color: #666;
  cursor: pointer;
}

.searchIcon {
  font-style: normal;
  margin-right: 5px;
}

/* 聊天消息区域 */
.chatMessages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  background-color: rgba(255, 255, 255, 0.1);
  scrollbar-width: thin;
  position: relative;
  z-index: 1;
  backdrop-filter: blur(5px);
}

.chatMessages::-webkit-scrollbar {
  width: 4px;
}

.chatMessages::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.chatMessages::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 2px;
}

.chatMessages::-webkit-scrollbar-thumb:hover {
  background: #ccc;
}

.message {
  margin-bottom: 20px;
  max-width: 85%;
  display: flex;
}

.agentMessage {
  align-self: flex-start;
}

.userMessage {
  margin-left: auto;
  justify-content: flex-end;
}

.systemMessage {
  align-self: center;
  text-align: center;
  color: #888;
  font-size: 12px;
  max-width: 100%;
  margin: 10px 0;
}

.agentAvatar {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  overflow: hidden;
  margin-right: 10px;
  flex-shrink: 0;
  background-color: #f7f7f7;
  display: flex;
  align-items: center;
  justify-content: center;
}

.agentAvatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.messageContent {
  display: flex;
  flex-direction: column;
}

.messageHeader {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
}

.agentName {
  font-weight: bold;
  font-size: 13px;
  margin-right: 8px;
  color: var(--huawei-dark-grey);
}

.messageTime {
  color: rgba(255, 255, 255, 0.8);
  font-size: 11px;
}

.messageText {
  padding: 10px 14px;
  border-radius: 4px;
  position: relative;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.4;
}

.agentMessage .messageText {
  background-color: #f0f2f5;  /* 更改为浅灰色背景 */
  color: var(--huawei-text);
  border-top-left-radius: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.userMessage .messageText {
  background-color: #1677ff;  /* 更改为蓝色背景 */
  color: white;
  border-top-right-radius: 0;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 4px rgba(22, 119, 255, 0.2);
}

.messageLink {
  color: inherit;
  text-decoration: underline;
}

/* 问题类型选择容器 */
.questionTypeContainer {
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin: 15px 0;
  overflow: hidden;
}

.questionTypeTitle {
  padding: 15px;
  font-weight: bold;
  text-align: center;
  border-bottom: 1px solid #eee;
}

.questionTypeItem {
  padding: 15px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.questionTypeItem:last-child {
  border-bottom: none;
}

.questionTypeItem:hover {
  background-color: #f9f9f9;
}

/* 聊天控制区域 */
.chatControls {
  flex-shrink: 0;
  padding: 15px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  background-color: rgba(10, 59, 125, 0.8);
  z-index: 2;
  position: relative;
}

/* 聊天模式切换控制 */
.chatModeSwitch {
  margin-bottom: 15px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.humanServiceBtn, .aiServiceBtn {
  padding: 6px 16px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s;
  border: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.humanServiceBtn {
  background-color: white;
  color: var(--huawei-red);
}

.aiServiceBtn {
  background-color: white;
  color: var(--huawei-red);
}

.humanServiceBtn:hover, .aiServiceBtn:hover {
  opacity: 0.9;
  transform: translateY(-2px);
}

.clearHistoryBtn {
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 16px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  margin-left: 10px;
}

.clearHistoryBtn:hover {
  background-color: rgba(255, 255, 255, 0.3);
  color: white;
}

.chatInput {
  display: flex;
  gap: 10px;
}

.chatInput input {
  flex: 1;
  padding: 12px 15px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  outline: none;
  font-size: 14px;
  background-color: rgba(255, 255, 255, 0.15);
  color: white;
}

.chatInput input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.chatInput input:focus {
  border-color: rgba(255, 255, 255, 0.5);
  background-color: rgba(255, 255, 255, 0.2);
}

.sendButton {
  background-color: white;
  color: var(--huawei-red);
  border: none;
  border-radius: 8px;
  padding: 0 20px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.sendButton:hover {
  background-color: rgba(255, 255, 255, 0.9);
  transform: translateY(-2px);
}

/* 响应式样式 */
@media (max-width: 1200px) {
  .chatWidget {
    width: 95%;
    height: 90%;
  }
  
  .chatContainer {
    grid-template-columns: 240px minmax(auto, 700px) 1fr;
  }
}

@media (max-width: 992px) {
  .chatContainer {
    grid-template-columns: 200px minmax(auto, 600px) 1fr;
  }
}

@media (max-width: 768px) {
  .chatContainer {
    grid-template-columns: 1fr;
  }
  
  .leftPanel {
    display: none;
  }
  
  .middlePanel {
    grid-column: 1;
  }
}

.particleContainer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}